<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
    <style>
        ul {
          width: 300px;
        }
        li {
          height: 40px;
          border-bottom: 1px solid #000;
        }
      </style>
</head>
<body>
    <div>
        <ul>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
        </ul>
    </div>
    <script>
        const oLis = document.querySelectorAll("ul li")
        function enter(){
            this.style.background ="pink"
        }
        function leave(){
            console.log(2);
            this.style.background = ""
        }
    const throttleEnter =  _.throttle(enter,30,{
            leading: true,
            trailing: false,
        })
        // const throttleLeave = leave
        //如果直接像处理一个元素节流那样把_.throttle()给每个li的onmouseenter事件，那么每个li的事件都是一个新的事件函数，就等于进入每一个li都会是第一次，就都会执行，所以我们要用一个变量保存_.throttle（），再给到li的onmouseenter事件，这样每个li拿到的都是同一个事件函数
        oLis.forEach((item)=>{
            item.onmouseenter = throttleEnter;
            item.onmouseleave = leave;
        });
    </script>
</body>
</html>